<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <th:block th:include="include::header" />
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>工艺名称</label>
                <div class="layui-input-block">
                    <select id="cr_name" name="pl_cr_name" lay-filter="pl_cr_name">
                        <option th:each="item:${list}" th:object="${item}" th:value="*{cr_name}" th:text="*{cr_name}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="pl_quantity" class="layui-form-label">
                    <span class="x-red">*</span>批次数量</label>
                <div class="layui-input-inline">
                    <input type="text" id="pl_quantity" name="pl_quantity" required="" lay-verify="pl_quantity"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="pl_start" class="layui-form-label">
                    <span class="x-red">*</span>计划开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="pl_start" name="pl_start" required="" lay-verify="pl_start" autocomplete="off"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="pl_end" class="layui-form-label">
                    <span class="x-red">*</span>计划结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="pl_end" name="pl_end" required="" lay-verify="pl_end"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="pl_submit" class="layui-form-label">
                    <span class="x-red">*</span>计划提交时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="pl_submit" name="pl_submit" required="" lay-verify="pl_submit"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="pl_cr_start" class="layui-form-label">
                    <span class="x-red">*</span>工艺计划开始时间  </label>
                <div class="layui-input-inline">
                    <input type="text" id="pl_cr_start" name="pl_cr_start" required="" lay-verify="pl_cr_start"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="pl_cr_end" class="layui-form-label">
                    <span class="x-red">*</span>工艺计划结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="pl_cr_end" name="pl_cr_end" required="" lay-verify="pl_cr_end"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            //指定元素
            elem: '#pl_start',
        });
        laydate.render({
            //指定元素
            elem: '#pl_end',
        });
        laydate.render({
            //指定元素
            elem: '#pl_submit',
        });
        laydate.render({
            //指定元素
            elem: '#pl_cr_start',
        });
        laydate.render({
            //指定元素
            elem: '#pl_cr_end',
        });
    });
</script>
<script>layui.use(['form', 'layer', 'jquery'],
    function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
        //监听提交
        form.on('submit(add)',
            function (data) {
                console.log(data);
                //发异步，把数据提交给php
                $.ajax({
                    url:"/craft/plan/add",
                    type: "POST",
                    data:data.field,
                    success(res){
                        if(res.success){
                            layer.alert("增加成功", {
                                    icon: 6
                                },
                                function () {
                                    //关闭当前frame
                                    xadmin.close();
                                    // 可以对父窗口进行刷新
                                    xadmin.father_reload();
                                });
                        }else{
                            layer.msg(res.msg)
                        }
                    }
                })
                return false;
            });

    });</script>
</body>

</html>